#ifndef _CHROMO_H_
#define _CHROMO_H_

#include<float.h> // for DBL_MAX
#include<iostream>
using namespace std;

class Chromo
{
 private:
  int size;
  int *seq;
  double fit;
  bool modified;

 public:

  // (de)Constructors
  Chromo();
  Chromo(int chromo_size, bool init = true);
  Chromo(const Chromo &copy);
  ~Chromo();
  void re_setup(int chromo_length, bool init = true); // change the chromo length and others

  //operator overloading
  Chromo& operator=(const Chromo &copy);
  bool operator<(const Chromo &t) const;
  bool operator>(const Chromo &t) const;
  friend ostream & 
    operator<<(ostream &os, const Chromo &t);


  // GA basic operation
  double fitness(double fitness = -DBL_MAX);
  int bit_mutate(int position);
  void rand_mutate(double rate);
  int crossover(Chromo &partner, int pos1, int pos2 = 0);
  int loci(int index, int value = -1);

  // utils functions
  int randseq();
  unsigned long debin() const; // decode the bin sequence to a integer
  int ham_dist(const Chromo &target) const; 
  bool if_modified();
};

#endif
